% ========================================
% Page layout
\RequirePackage[left=1.45in,right=1.45in,top=1in,bottom=1in]{geometry}
\usepackage{color}

% fancyhdr
\fancypagestyle{bodypage}{%
\fancyhf{}% clear all six fields
\fancyhead[RE,LO]{\small Other problems and answers: Introduction to Proofs}
\fancyhead[LE,RO]{\small page \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
}

\pagestyle{bodypage}
\AtBeginDocument{\thispagestyle{firstpage}}

% ========================================
% make cross referrences to main text
\RequirePackage{xr}
\externaldocument{ibl} 


% ========================================
% use facilities of package enumitem
\newlength{\unifiedlistparindent}  % use same value in lists and sublists
\setlength{\unifiedlistparindent}{1.25em}  
\newlength{\unifiedinterexerciseverticalspace}
\setlength{\unifiedinterexerciseverticalspace}{0.75ex plus 0.02ex minus 0.01ex}


\newenvironment{otherproblem}[1]{% Note that answer comes inside this env
  \begin{itemize}[topsep=\unifiedinterexerciseverticalspace,
                  partopsep=0ex, parsep=0ex plus 0.01ex,
                  beginpenalty=150,% Prevent page break after newline start
                  labelwidth=0em,align=left,labelsep=0em,
                  itemindent=0em,
                  itemsep=.25ex plus .03ex minus .01ex,
                  leftmargin=0em,rightmargin=0em,
                  listparindent=\unifiedlistparindent,
                  align=left,label={}]\item[\textsc{Exercise near #1.}]\  % 
}{%
  \end{itemize}
}

% \newlength{\exesindent}\setlength{\exesindent}{1.25em}
\newenvironment{exes}{%
  \begin{enumerate}[topsep=0.15ex plus 0.02ex minus 0.01ex,
                    partopsep=0ex,parsep=0ex,
                    beginpenalty=150,   % Prevent page break after newline start
                    labelwidth=0.5em plus .03em minus 0em,align=right,labelsep=0.5em,
                    itemsep=.25ex plus .04ex,
                    leftmargin=0em,
                    itemindent=1em,
                    rightmargin=0em,
                    listparindent=\unifiedlistparindent,
                    align=left,label={\textsc{\alph*}.}] 
}{%
  \end{enumerate}
}

% Note that his is redefined in the answer environment, and in the
% exes environment, so this definition doesn't change anything.
\newenvironment{solution}[1]{%
  \item %
}{%
}

\newenvironment{exercise}{%
  \item %
}{%
}
\newenvironment{answer}{%
  \par\noindent\textsc{Answer.}\  %
}{%
}
\newenvironment{ans}{%
  \par\noindent\textsc{Answer.}\  %
}{%
}



%
\renewenvironment{items}{%
\begin{enumerate}[topsep=0.15ex plus 0.02ex minus 0.01ex,
                  partopsep=0ex,parsep=0ex,
                  beginpenalty=150,   % Prevent page break after newline start
                  labelwidth=0.5em plus .03em minus 0em,align=right,labelsep=0.5em,
                  itemsep=.25ex plus .04ex,
                  leftmargin=0em,
                  itemindent=1em,
                  rightmargin=0em,
                  listparindent=\unifiedlistparindent,
                  align=left,label={(\roman*)}] 
}{%
\end{enumerate}
}


\newenvironment{otherexercise}[1]{%
  \vspace{\unifiedinterexerciseverticalspace}\par\noindent
  \textsc{Exercise near #1.}\hspace*{0.5em}
}{%
}

% \newenvironment{otherproblem}[1]{%
%   \vspace{\unifiedinterexerciseverticalspace}\par\noindent
%   \textsc{Exercise near #1.}\hspace*{0.5em}
% }{%
% }

\newenvironment{otheranswer}[1]{%
  \par\noindent
  \textsc{Answer.}\hspace*{0.5em}
}{%
}

% ==============================================
% sectioning
\titleformat{\chapter}[block]{\color{darki}\LARGE\scshape}{Chapter \thechapter}{1em}{}[\thispagestyle{firstpage}]
\titlespacing*{\chapter}{0em}{6ex}{3ex} 
\titleformat{\section}[block]{\color{darki}\Large\scshape}{}{0em}{}[]
\titlespacing*{\section}{0em}{7ex}{2ex} 

% \titleformat{\section}[block]{\Large\scshape}{}{0em}{}[] % unnumbered sections
% \titlespacing*{\section}{0em}{7ex}{2ex} 
